<template>
	<view>
		<view class="" style="margin:20rpx auto;width: 700rpx;">
			<u-image :src="info.cover" width="700" height="240" border-radius="20"></u-image>
		</view>

		<view class="">
			<view>
				<view class="paddings u-flex u-row-between" @click="moreCoupond">
					<view style="font-weight: bold;font-size: 30rpx;">{{info.storeName}}</view>			
					<view  class="$u-tips-color u-font-sm">优惠券<u-icon name="arrow-right" color="$u-tips-color"></u-icon></view>	
				</view>

				<view class="u-flex u-row-between u-border-bottom paddings">
					<view class="">
						<u-rate v-model="info.score" active-color="#FABE00"></u-rate>
						<text style="color: #FABE00;margin-left: 20rpx;">{{info.score}}分</text>
					</view>
				</view>

				<view class="u-flex u-row-between $u-tips-color  paddings" @click="openMap(info.lat,info.lng)">
					<view>
						{{info.address}}
					</view>
					<view class="u-flex">
							距离您{{info.distance}}
						 <u-icon name="arrow-right" color="$u-tips-color"></u-icon>
					</view>
				</view>

				<u-gap height="10" bg-color="#f1f1f1"></u-gap>
                <view class="paddings">
					<u-section title="店铺服务" @click="moreGood" ></u-section>
					
					<List :list="list"></List>
				</view>

				<u-gap height="10" bg-color="#f1f1f1"></u-gap>
                <view class="paddings">
					<u-section title="用户评价" @click="morecomment"  ></u-section>
					
					<Comment :list="comment"></Comment>
				</view>



			</view>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import url from '@/common/baseUrl.js';
	import List from "./components/goods";
	
	import Comment from "./components/comment";
	export default {
		
		components:{
			List,
			Comment
		},
		data() {
			return {
				id: "",
				info: {

				},
				list: [],
				comment:[],
				imagesurl: url.imageUrl,
			}
		},
		onLoad(options) {
			if (options.id) {
				this.id = options.id
			}
			this.get()
			this.getgoodsList()
			this.getcommentList()
		},
		methods: {
			moreGood(){
				uni.navigateTo({
					url:'./moreGoods?id='+this.id
				})
			},
			morecomment(){
				uni.navigateTo({
					url:'./moreComment?id='+this.id
				})
			},
			openMap(lat,lng){
				uni.openLocation({
					latitude:Number(lat),
					longitude:Number(lng),
					address:this.info.address
				})
			},
			getgoodsList(){
				this.$u.post('/api/index/storeGoods', {
					store_id: this.id,
					page: 1,
					limit: 3
				}).then(res => {
					this.list = res;
				}).catch(err => {
				
				})
			},
			getcommentList(){
				this.$u.post('/api/index/evaluate', {
					store_id: this.id,
					page: 1,
					limit: 3
				}).then(res => {
					this.comment = res;
				}).catch(err => {
				
				})
			},
			
			moreCoupond() {
				uni.navigateTo({
					url: '../../pages/list/moreCoupond?id=' + this.info.id
				})
			},
	
			getCoupond() {
				this.$u.post('/api/index/coupon', {
					store_id: this.id,
					page: 1,
					limit: 3
				}).then(res => {
					this.Coupond = res;

				}).catch(err => {

				})
			},
	
			
			get() {
				this.$u.post('/api/index/storeDetail', {
					store_id: this.id,
					lat: this.$store.state.location.lat ? this.$store.state.location.lat : 0,
					lng: this.$store.state.location.lng ? this.$store.state.location.lng : 0,
				}).then(res => {
					var info = res;
					info.score = Number(res.score);
					this.info = info;

				}).catch(err => {

				})
			},
			
		}
	}
</script>

<style>
	.paddings {
		padding: 20rpx 30rpx;
	}
	
	.list{
		padding: 20rpx 0!important;
		width: 100%!important;
		margin: 0!important;
	}

</style>
